<!DOCTYPE html>
<html>
	<head>
		<title>Pydio</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="icon" type="image/x-png" href="plugins/gui.ajax/res/themes/orbit/images/html-folder.png">
		<script src="plugins/gui.ajax/res/js/vendor/prototype/prototype.js" type="text/javascript"></script>
        <style>
            * {
                font-family: Roboto, sans-serif;
            }
            body {
                background-color: #ECEFF1;
                margin: 0;
                padding: 20px;
            }
            h1 {
                font-size: 30px;
                font-weight: normal;
                color: #555;
                height: 20px;
                text-align: center;
                margin: 10px auto;
            }

            div.mainContainer{
                position: relative;
                margin: 36px auto;
                width: 660px;
                height: 80%;
                padding: 7px 11px;
            }

            p.status{
                margin-top: 0;
                font-size: 15px;
                line-height: 20px;
                text-align: justify;
                height: 60px;
                padding: 0 5px;
            }
            p.status a{
                display: inline-block;
                float: right;
                background-color: #009688;
                color: white;
                text-transform: uppercase;
                padding: 6px 13px;
                text-decoration: none;
                border-radius: 1px;
                margin: 10px 0;
                box-shadow: 0 2px 3px rgba(0,0,0,.16),0 2px 3px rgba(0,0,0,.43);
            }
            p.status strong{
                font-weight: normal;
                font-style: italic;
            }

            div.testList{
                margin: 0 auto;
            }

            div.testLine {
                text-align: left;
                padding: 15px 15px 9px;
                margin: 4px 3px;
                background-color: #ffffff;
                box-shadow: 0 1px 2px rgba(0,0,0,.10),0 1px 1px rgba(0,0,0,.33);
                border-radius: 1px;
            }
            div.testClear{
                clear:both;
                height: 8px;
            }
            div.testName{
                float: left;
                width: 80%;
                cursor: pointer;
                font-size: 16px;
                color: #000;
            }
            div.testName span{
                display: none;
            }
            div.testStatus{
                float: right;
                width: 20%;
                text-transform: uppercase;
                text-align: right;
                color: #090;
                margin-top: 3px;
            }
            div.testLine.error .testStatus{
                color : #933;
            }
            div.testLine.warning .testStatus{
                color: #f90;
            }
            div.testDescription{
                font-size: 12px;
                color: rgba(0, 0, 0, 0.43);
                clear: both;
                padding: 9px 0 5px;
                font-weight: 500;
            }
            div.testDescription.visible
            {
                display: block;
            }
            p.suggestion{
                margin:5px 0 0;
            }

        </style>

	</head>
	<body bgcolor="#FFFFFF" text="#000000" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0"  style="">

        <h1>Pydio Diagnostic Tool</h1>

        <div class="mainContainer">
            <?php
                if ($showSkipLink) {
                    if (count($ALL_ROWS["warning"]) && !count($ALL_ROWS["error"])) {
                        echo "<p class='status statusWarning'><strong>Status</strong> : You have some warnings, but no fatal error detected, Pydio should run ok. <br/>Please review the warnings. <a href='?ignore_tests=true'>Continue to Pydio Installation</a></p>";
                    } else if(count($ALL_ROWS["error"])) {
                        echo "<p class='status statusError'><strong>Status</strong> : <b>You have some errors</b> that may prevent Pydio from running. Please review the error lines to check what action you should do. <a href='?ignore_tests=true'>Ignore and continue to Pydio</a>.</p>";
                    }else{
                        echo "<p class='status'><strong>Status</strong> : <b>No specific errors</b> were detected, your Pydio installation should run smoothly! <br/><a href='?ignore_tests=true'>Continue to Pydio Installation!</a></p>";
                    }
                }
            ?>

            <div class="testList">
            <?php

                foreach ($ALL_ROWS as $testsType => $allTests){

                    foreach($allTests as $testKey => $testInfo){

                        $status = ($testsType == "passed"?"ok":$testsType);
                        echo "<div class='testLine $testsType'>
                            <div class='testName'><span>".($testsType != "passed"?"-":"+")."</span> $testKey</div>
                            <div class='testStatus'>$status</div>
                            <div class='testDescription ".($testsType != "passed"?" visible":"")."'>$testInfo</div>
                            <div class='testClear'></div>
                        </div>";

                    }

                }

            ?>
            </div>

            <script type="text/javascript">
                var testAllowOverride = new Ajax.Request('data/cache/index.html', {
                    method : 'get',
                    onComplete : function(response){
                        if(200 === response.status){
                            var html = '<div class="testLine error">\
                                <div class="testName"><span>-</span>Security Breach</div>\
                                <div class="testStatus">error</div>\
                                <div class="testDescription  visible">It seems that your <b>data/</b> folder is not correctly protected, and that subfolders (like the data/cache/ folder) are web-accessible. If you are using <b>Apache</b>, make sure the AllowOverride All option is active for your current directory. If you are running <b>Windows IIS</b>, you must manually add a RequestFiltering/HiddenSegments configuration to prevent web access to these folders. If you have defined a different AJXP_DATA_PATH pointing outside the webfolder, you can ignore this warning.</div>\
                                <div class="testClear"></div>\
                            </div>';
                            $$('div.testList')[0].insert({top:html});
                        }
                    }
                });
                /*
                var testRewrite = new Ajax.Request('public/', {
                    method : 'get',
                    onComplete : function(response){
                        if(404 === response.status){
                            var html = '<div class="testLine error">\
                                <div class="testName"><span>-</span>RewriteRule does not seem to work</div>\
                                <div class="testStatus">error</div>\
                                <div class="testDescription  visible">Testing access to <b>public/</b> should give an empty link page but gives a 404, which seems to indicate that your server is not configure to support RewriteRules. If you are using <b>Apache</b>, make sure the ModRewrite is active. For other servers, check pydio install folder where you may find proper configuration files (web.config.sample, nginx.sample)</div>\
                                <div class="testClear"></div>\
                            </div>';
                            $$('div.testList')[0].insert({top:html});
                        }
                    }
                });
                */

                $$('div.testName').invoke("observe", "click", function(event){
                    var target = event.target;
                    if(target.tagName.toLowerCase() == "span") target = target.up("div.testName");
                    target.next("div.testDescription").toggleClassName("visible");
                    if(target.next("div.testDescription").hasClassName("visible")){
                        target.down("span").update("-");
                    }else{
                        target.down("span").update("+");
                    }
                });
                var resize = function(){
                    var h1 = document.viewport.getHeight() - 120 ;
                    var h = h1 - 80;
                    $$("div.mainContainer")[0].setStyle({height:h1+'px'});
                    $$("div.testList")[0].setStyle({height:h + 'px'});
                };
                Event.observe(window, "resize", resize);
                resize();
            </script>
        </div>

        <!-- <h1 style="text-align: right">Continue to Pydio &gt;&gt; </h1>-->
    </body>
</html>